package com.ruoyi.system.service.impl;

import java.util.ArrayList;
import java.util.List;
import cn.hutool.core.util.ObjectUtil;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.ADictArea;
import com.ruoyi.system.domain.ADictBudget;
import com.ruoyi.system.domain.vo.ADictNatureALLVO;
import com.ruoyi.system.domain.vo.ADictNatureHG;
import com.ruoyi.system.domain.vo.ADictNatureSubVO;
import com.ruoyi.system.mapper.ADictAreaMapper;
import com.ruoyi.system.mapper.ADictBudgetMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.ADictNatureMapper;
import com.ruoyi.system.domain.ADictNature;
import com.ruoyi.system.service.IADictNatureService;

/**
 * 字典房屋性质/用途Service业务层处理
 *
 * @author gf
 * @date 2024-11-23
 */
@Service
public class ADictNatureServiceImpl implements IADictNatureService {
    @Autowired
    private ADictNatureMapper aDictNatureMapper;

    @Autowired
    private ADictAreaMapper aDictAreaMapper;

    @Autowired
    private ADictBudgetMapper aDictBudgetMapper;


    /**
     * 查询字典房屋性质/用途
     *
     * @param id 字典房屋性质/用途主键
     * @return 字典房屋性质/用途
     */
    @Override
    public ADictNature selectADictNatureById(Long id) {
        return aDictNatureMapper.selectADictNatureById(id);
    }

    /**
     * 查询字典房屋性质/用途列表
     *
     * @param aDictNature 字典房屋性质/用途
     * @return 字典房屋性质/用途
     */
    @Override
    public List<ADictNatureHG> selectADictNatureList(ADictNature aDictNature) {
        return aDictNatureMapper.selectADictNatureList(aDictNature);
    }

    /**
     * 新增字典房屋性质/用途
     *
     * @param aDictNature 字典房屋性质/用途
     * @return 结果
     */
    @Override
    public int insertADictNature(ADictNature aDictNature) {
        aDictNature.setCreateTime(DateUtils.getNowDate());
        return aDictNatureMapper.insertADictNature(aDictNature);
    }

    /**
     * 修改字典房屋性质/用途
     *
     * @param aDictNature 字典房屋性质/用途
     * @return 结果
     */
    @Override
    public int updateADictNature(ADictNature aDictNature) {
        aDictNature.setUpdateTime(DateUtils.getNowDate());
    return aDictNatureMapper.updateADictNature(aDictNature);
    }

    /**
     * 批量删除字典房屋性质/用途
     *
     * @param ids 需要删除的字典房屋性质/用途主键
     * @return 结果
     */
    @Override
    public int deleteADictNatureByIds(Long[] ids) {
        return aDictNatureMapper.deleteADictNatureByIds(ids);
    }

    /**
     * 删除字典房屋性质/用途信息
     *
     * @param id 字典房屋性质/用途主键
     * @return 结果
     */
    @Override
    public int deleteADictNatureById(Long id) {
        return aDictNatureMapper.deleteADictNatureById(id);
    }

    /**
     * 批量逻辑删除字典房屋性质/用途
     *
     * @param ids 需要删除的字典房屋性质/用途主键
     * @return 结果
     */
    @Override
    public int logicDeleteADictNatureByIds(Long[] ids) {
        return aDictNatureMapper.logicDeleteADictNatureByIds(ids);
    }
    /**
     * 逻辑删除字典房屋性质/用途信息
     *
     * @param id 字典房屋性质/用途主键
     * @return 结果
     */
    @Override
    public int logicDeleteADictNatureById(Long id) {
        return aDictNatureMapper.logicDeleteADictNatureById(id);
    }

    @Override
    public List<ADictNature> selectADictNatureXcxList(ADictNature aDictNature) {
        return aDictNatureMapper.selectADictNatureXcxList(aDictNature);
    }

    @Override
    public List<ADictNatureALLVO> selectADictNatureXcxAllList(ADictNature aDictNature) {
        List<ADictNatureALLVO> list = new ArrayList<ADictNatureALLVO>();

        List<ADictNatureSubVO> subVo = aDictNatureMapper.selectADictNatureShopList(aDictNature.getShopId());
        ADictNatureALLVO ture = new ADictNatureALLVO();
        ture.setTitle("店铺类型");
        ture.setKey("one");
        ture.setIsMutiple("false");
        ture.setDetailTitle("请选择（店铺类型）");
        ADictNatureSubVO subVO =  new ADictNatureSubVO();
        subVO.setTitle("不限");
        subVO.setValue("0");
        subVo.set(0,subVO);
        ture.setDetailList(subVo);
        list.add(ture);

        ADictNatureALLVO area = new ADictNatureALLVO();
        List<ADictNatureSubVO> areas = aDictAreaMapper.selectADictAreaXcxSubList();
        area.setId(aDictNature.getShopId());
        area.setTitle("租金");
        area.setKey("two");
        area.setIsMutiple("false");
        area.setDetailTitle("请选择（租金）");
        area.setDetailList(areas);
        list.add(area);

        ADictNatureALLVO bud = new ADictNatureALLVO();
        List<ADictNatureSubVO> budgets = aDictBudgetMapper.selectADictBudgetXcxSubList();
        bud.setId(aDictNature.getShopId());
        bud.setTitle("面积");
        bud.setKey("three");
        bud.setIsMutiple("false");
        bud.setDetailTitle("请选择（面积）");
        bud.setDetailList(budgets);
        list.add(bud);

        return list;
    }

}
